package jdbc.day01;

import Utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JdbaUtilsDemo {
    public static void main(String[] args) {
        ResultSet resu=null;
        PreparedStatement pre=null;
        Connection conn=null;
        try {
            conn = JDBCUtils.getConnection();
            String st="select name,age from student where id=?";
             pre = conn.prepareStatement(st);
            pre.setInt(1,1);
             resu = pre.executeQuery();
            while (resu.next()){
                System.out.println(resu.getString("name")+"----"+resu.getInt("age"));
            }
        } catch (Exception throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtils.close(resu,pre,conn);
        }


    }
}
